package com.sun.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sun.dao.RoleMapper;
import com.sun.dao.RoomMapper;
import com.sun.pojo.Role;
import com.sun.pojo.Room;
import com.sun.service.RoleService;
import com.sun.service.RoomService;
import com.sun.utils.DataGridViewResult;
import com.sun.vo.RoleVo;
import com.sun.vo.RoomVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

@Service
@Transactional
public class RoomServiceImpl implements RoomService {


    @Autowired
    private RoomMapper roomMapper;

    public DataGridViewResult findAll(RoomVo roomVo) {
        PageHelper.startPage(roomVo.getPage(),roomVo.getLimit());
        List<Room> all = roomMapper.findAll(roomVo);
        PageInfo<Room> pageInfo = new PageInfo<Room>(all);
        return new DataGridViewResult(pageInfo.getTotal(),pageInfo.getList());
    }

    public int addRoom(Room room) {
        return roomMapper.addRoom(room);
    }

    public int updateRoom(Room room) {
        return roomMapper.updateRoom(room);
    }

    public int deleteRoom(int id) {
        return roomMapper.deleteRoom(id);
    }

    public List<Room> initAll() {
        return roomMapper.initAll();
    }

    public Room findOne(int id) {
        return roomMapper.findOne(id);
    }

    public List<Room> findRoomList(RoomVo roomVo) {
        return roomMapper.findRoomList(roomVo);
    }
}
